1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.client.samples.cda;
15
16 import java.io.IOException;
17
18 import javax.servlet.ServletException;
19 import javax.servlet.http.HttpServlet;
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22 import javax.servlet.http.HttpSession;
23
24 import uk.nhs.interoperability.transform.TransformManager;
25 import uk.nhs.interoperability.util.Logger;
26
27
28
29
30
31
32
33
34 public class CDAView extends HttpServlet {
35
36
37 private static final long serialVersionUID = 1L;
38
39
40
41
42
43
44 public CDAView() {
45 super();
46
47 }
48
49
50
51
52
53
54
55
56
57
58 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
59
60 String docId = request.getParameter("docid");
61 Logger.trace("Document ID:"+docId);
62 HttpSession session = request.getSession(true);
63 session.removeAttribute("errorMessage");
64 session.removeAttribute("outcomeMessage");
65 session.removeAttribute("responseMessage");
66
67 String document = DocStore.getDocument(docId);
68
69 if (null!=document){
70 String htmlResponse = "";
71 try {
72 htmlResponse = TransformManager.doTransform("CDA_NPfIT_Document_Renderer.xsl", document);
73 session.setAttribute("outcomeMessage", "CDA Message Sent.");
74 session.setAttribute("responseMessage", htmlResponse);
75 } catch (Exception e) {
76 Logger.error("Document Transform failed:",e);
77 session.setAttribute("errorMessage", "Document Transform Failed.");
78 }
79 Logger.trace(htmlResponse);
80 } else {
81 Logger.trace("Document not found");
82 session.setAttribute("errorMessage", "Document Not Found.");
83 }
84 response.sendRedirect("./CDAView.jsp");
85 }
86
87
88
89
90
91
92
93
94
95
96 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
97
98 System.out.println("this is doPost");
99 String docId= request.getParameter("docid");
100 response.getWriter().write("DO POST. DOCID:"+docId);
101 }
102
103 }